package org.action;

import java.util.List;
import java.util.Map;

import org.bean.O2rankgame;
import org.service.GameService;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class PlayerCapableDetailsAction extends ActionSupport {

	private O2rankgame o2rankgame;
	private GameService gameservice;
	private int uid;
	private Map session;	
	private int mlevel;
	private String nickname;
	private List<O2rankgame> list;
	private double score;
	
	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		score=0;
		Map request = (Map) ActionContext.getContext().get("request");
	
		
		 list =gameservice.SelectTopCapable(uid);
		
		for (int i = 0; i < list.size(); i++) {
			O2rankgame o2rankgame = list.get(i);
			
			score = score+o2rankgame.getCapable();
			
			
			if (o2rankgame.getMhard().equals("高级")) {
			mlevel = o2rankgame.getO2ranksongs().getHardlevel();
		} else if (o2rankgame.getMhard().equals("中级")) {
			mlevel = o2rankgame.getO2ranksongs().getNormallevel();
		} else {
			mlevel = o2rankgame.getO2ranksongs().getEasylevel();
		}

		o2rankgame.setUnknown3(String.valueOf(mlevel));
		if (i == list.size() - 1) {
			nickname = o2rankgame.getNickname();
		}
	}

		score = score/10;

		request.put("list", list);
		return SUCCESS;
	}


	public O2rankgame getO2rankgame() {
		return o2rankgame;
	}


	public void setO2rankgame(O2rankgame o2rankgame) {
		this.o2rankgame = o2rankgame;
	}


	public GameService getGameservice() {
		return gameservice;
	}


	public void setGameservice(GameService gameservice) {
		this.gameservice = gameservice;
	}


	public int getUid() {
		return uid;
	}


	public void setUid(int uid) {
		this.uid = uid;
	}


	public Map getSession() {
		return session;
	}


	public void setSession(Map session) {
		this.session = session;
	}


	public String getNickname() {
		return nickname;
	}


	public void setNickname(String nickname) {
		this.nickname = nickname;
	}


	public List<O2rankgame> getList() {
		return list;
	}


	public void setList(List<O2rankgame> list) {
		this.list = list;
	}


	public double getScore() {
		return score;
	}


	public void setScore(double score) {
		this.score = score;
	}
	
	
}
